package com.tx.axure.tkaxureweb.controller;

import com.tx.axure.tkaxureweb.annotation.LoginRequired;
import com.tx.axure.tkaxureweb.service.IFilesService;
import com.tx.axure.tkaxureweb.vo.ResultVoMap;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RestController
@RequestMapping("/files")
public class FilesController {

    private final IFilesService filesService;

    //swagger3写法
    @LoginRequired
    @PostMapping(value = "/upload/{prodId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResultVoMap uploadFile(@PathVariable Integer prodId,@RequestPart("file") MultipartFile file) {
        return filesService.uploadFile(file,prodId);
    }

}


